<?php
/*
	@version		$Id: template_config.php 76 2010-01-22 00:50:31Z bulletprooftemplates $
	@copyright		Copyright (C) 2007-2010 Waseem Sadiq. All rights reserved.
	@license		Single Domain License
*/


/*
	Additional Template Functionality

	@package		Joomla!
	@subpackage		1.5
	@version		1.5
*/
defined('_JEXEC') or die('Restricted access');

$template_url = $this->baseurl. '/templates/' . $this->template;
$style_url = $this->baseurl . '/templates/' . $this->template . '/css';
$script_url = $this->baseurl . '/templates/' . $this->template . '/javascript';
$img_url = $this->baseurl . '/templates/' . $this->template . '/images';

$leftcolumn = $this->countModules('left');
$rightcolumn = $this->countModules('right');

$left = ($leftcolumn ? 1 : 0);
$right = ($rightcolumn ? 1 : 0);


if ($left &! $right) $style 	= "left-only";
if (!$left && $right) $style 	= "right-only";
if (!$left &! $right) $style 	= "wide";
if ($left && $right) $style 	= "both";

#--------------------------------------------------------------------------#
	
$firsttopmodule = $this->countModules('user1');
$secondtopmodule = $this->countModules('user2');
$thirdtopmodule = $this->countModules('user3');
$fourthtopmodule = $this->countModules('user4');

#--------------------------------------------------------------------------#

$topmodule1 = ($firsttopmodule ? 1 : 0);
$topmodule2 = ($secondtopmodule ? 1 : 0);
$topmodule3 = ($thirdtopmodule ? 1 : 0);
$topmodule4 = ($fourthtopmodule ? 1 : 0);

$toptotal = ($topmodule1 + $topmodule2 + $topmodule3 + $topmodule4);

#--------------------------------------------------------------------------#

$firstbottommodule = $this->countModules('user5');
$secondbottommodule = $this->countModules('user6');
$thirdbottommodule = $this->countModules('user7');
$fourthbottommodule = $this->countModules('user8');

#--------------------------------------------------------------------------#

$bottommodule1 = ($firstbottommodule ? 1 : 0);
$bottommodule2 = ($secondbottommodule ? 1 : 0);
$bottommodule3 = ($thirdbottommodule ? 1 : 0);
$bottommodule4 = ($fourthbottommodule ? 1 : 0);

$bottomtotal = ($bottommodule1 + $bottommodule2 + $bottommodule3 + $bottommodule4);

#--------------------------------------------------------------------------#

function getPageCssFile (){
global $mainframe;

$template = $mainframe->getTemplate();
$pagecssfile = "";

$page_specific_css_file = JPATH_THEMES.DS. $template .DS.'page'.DS.'page'. JRequest::getInt('Itemid', 0) .'.css';

	if (file_exists($page_specific_css_file)) 
	{
	$pagecssfile = '<link href="templates/' . $template .'/page/page' . JRequest::getInt('Itemid', 0) .'.css" rel="stylesheet" type="text/css" media="screen" />';
}
	return $pagecssfile;
}

#--------------------------------------------------------------------------#

function getPageIndexFile(){
global $mainframe;

$template = $mainframe->getTemplate();
$pageindexfile = "";

$page_specific_index_file = JPATH_THEMES.DS. $template .DS.'page'.DS.'page'. JRequest::getInt('Itemid', 0) .'.php';

	if (file_exists($page_specific_index_file)) 
	{
	$pageindexfile = $page_specific_index_file;
}
	return $pageindexfile;
}

#--------------------------------------------------------------------------#

function getPageId()
{
   return JRequest::getInt('Itemid', 0);
}

#--------------------------------------------------------------------------#

function getSection($iId) {
  $database = &JFactory::getDBO();
  if(JRequest::getVar( 'view', 0) == "section"){
    return JRequest::getVar( 'id', 0);
  }else if(Jrequest::getVar( 'view', 0) == "category"){
    $sql = "SELECT section FROM #__categories WHERE id = $iId ";
    $database->setQuery( $sql );
    $row=$database->loadResult();
    return $row;
  }else if(Jrequest::getVar('view', 0) == "article"){
    $temp=explode(":",JRequest::getVar('id',0));
    $sql = "SELECT sectionid FROM #__content WHERE id = ".$temp[0];
    $database->setQuery( $sql );
    $row=$database->loadResult();
    return $row;
  }		
}
$section_id=getSection(JRequest::getVar('id',0));

#--------------------------------------------------------------------------#

function getSectionCssFile (){
global $mainframe;

$template = $mainframe->getTemplate();
$sectioncssfile = "";

$section_specific_css_file = JPATH_THEMES.DS. $template .DS.'page'.DS.'section'. getSection(JRequest::getVar('id',0)) .'.css';

	if (file_exists($section_specific_css_file)) 
	{
	$sectioncssfile = '<link href="templates/' . $template .'/page/section' . getSection(JRequest::getVar('id',0)) .'.css" rel="stylesheet" type="text/css" media="screen" />';
}
	return $sectioncssfile;
}

#--------------------------------------------------------------------------#

function getCurrentAlias()
{
return JSite::getMenu()->getActive()->alias;
}

?>